

let a = new Promise((resolve, reject) => {
  resolve('a')
})

let b = new Promise((resolve, reject) => {
  resolve('b')
})

let c = new Promise((resolve, reject) => {
  reject('c')
})





Promise.MyAllSettled = function (promises) {
  let arr = [],
    count = 0
  return new Promise((resolve, reject) => {
    promises.forEach((item, i) => {
      Promise.resolve(item)
        .then(res => {
          arr[i] = { status: 'fulfilled', val: res }
          count += 1
          if (count === promises.length) resolve(arr)
        })
        .catch(err => {
          arr[i] = { status: 'rejected', val: err }
          count += 1
          if (count === promises.length) resolve(arr)
        })
        
    })
    
  })
}


let test = Promise.MyAllSettled([a, b, c])
test.then(res => console.log(res))